﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ControleurAccesMetier
{
    class CoucheAccesMetier
    {
        private FactoryMessage.STGMSG oMsg;
        private ControleurWorkflow.I_CTRL_WF WF_exec;

        public FactoryMessage.STGMSG redirection(FactoryMessage.STGMSG oMsg)
        {
            if ((oMsg.Invoke == "p_authentifier") && (oMsg.App_Name == "Application1_v1"))
            {
                this.WF_exec = new ControleurWorkflow.CTRL_WF_AUTH_V1();
                this.oMsg = this.WF_exec.exec(oMsg);
            }
            else if ((oMsg.Invoke == "p_listeSite") && (oMsg.App_Name == "Application1_v1") && (oMsg.token == "tokenSecurity1234"))
            {
                this.WF_exec = new ControleurWorkflow.CTRL_WF_LISTESITES_V1();
                this.oMsg = this.WF_exec.exec(oMsg);
            }
            else if ((oMsg.Invoke == "p_nouveauSite") && (oMsg.App_Name == "Application1_v1") && (oMsg.token == "tokenSecurity1234"))
            {
                this.WF_exec = new ControleurWorkflow.CTRL_WS_NV_SITE_V1();
                this.oMsg = this.WF_exec.exec(oMsg);
            }
            else if ((oMsg.Invoke == "p_nv_personne") && (oMsg.App_Name == "Application1_v1") && (oMsg.token == "tokenSecurity1234"))
            {
                this.WF_exec = new ControleurWorkflow.CTRL_WF_NV_PERSONNE_V1();
                this.oMsg = this.WF_exec.exec(oMsg);
            }
            else if ((oMsg.Invoke == "p_employesSite") && (oMsg.App_Name == "Application1_v1") && (oMsg.token == "tokenSecurity1234"))
            {
                this.WF_exec = new ControleurWorkflow.CTRL_WF_EMPLSITE_V1();
                this.oMsg = this.WF_exec.exec(oMsg);
            }
            else if ((oMsg.Invoke == "p_ListeEmployes") && (oMsg.App_Name == "Application1_v1") && (oMsg.token == "tokenSecurity1234"))
            {
                this.WF_exec = new ControleurWorkflow.CTRL_WF_LISTE_EMPL_V1();
                this.oMsg = this.WF_exec.exec(oMsg);
            }
            else
            {
                this.oMsg = FactoryMessage.MSG_FACTORY.msg_factory("", null, "La fonctionnalité demandé n'est pas disponible pour votre application ou vos droits sont insufisant.", "", "", false, "");
            }

            return this.oMsg;
        }

    }
}
